/*  

Cafechess Library: Cover basic chess programming needs, like GUI, Engine integration, 
FEN and PGN parsing.

                 \\|//
                 (o o)
--------------ooO-(_)-Ooo----------------------------------
Copyright (C) 2009  By Gregory A. Prentice Snoqualmie, WA
                    www.cafechess.org
                    cafechess@comcast.net
                      Oooo
--------------oooO----(  )---------------------------------
              (  )    (_/
               \_)

Microsoft Public License (Ms-PL)
               
Revisions:

Author        Date    Description:

*/
using System;
using Cafechess.General;
namespace Cafechess.Chess.Validation
{
  using Bitboard = System.UInt64;

  /// <summary>
  /// Sets the bitboards for all of the pieces that may be checking a king.
  /// Also keeps track of how many pieces are checking the king.  This is used
  /// for mate detection.
  /// </summary>
  //[CLSCompliant(false)]
  public class AttackingPieces
  {
    public int Count
    {
      get{return coCount;}
    }
    private int coCount;

    /// <summary>
    /// Bitboard for attacked diagonals moving left to right.
    /// </summary>
    public Bitboard DiagonalLR
    { 
      get{ return coDiagonalLR;}
      set{ coDiagonalLR = value;}
    }
    private Bitboard coDiagonalLR;

    /// <summary>
    /// Bitboard for attacked diagonals moving right to left.
    /// </summary>
    public Bitboard DiagonalRL
    { 
      get{ return coDiagonalRL;}
      set{ coDiagonalRL = value;}
    }   
    private Bitboard coDiagonalRL;
    
    /// <summary>
    /// Bitboard for attached ranks.
    /// </summary>
    public Bitboard Ranks
    { 
      get{ return coRanks;}
      set{ coRanks = value;}
    }
    private Bitboard coRanks;

    /// <summary>
    /// Bitboards of attached files
    /// </summary>
    public Bitboard Files
    { 
      get{ return coFiles;}
      set{ coFiles = value;}
    }
    private Bitboard coFiles;
    
    /// <summary>
    /// Bitboard for our Queens.
    /// </summary>
    public Bitboard Queen
    {
      get{ return coQueen;}
      set{ coQueen = value;if(coQueen != 0 )coCount++;}
    }
    private Bitboard coQueen;
    /// <summary>
    /// Bitboard for our Rooks.
    /// </summary>
    public Bitboard Rook
    {
      get{ return coRook;}
      set{ coRook = value;if(coRook != 0 )coCount++;}
    }
    private Bitboard coRook;
    /// <summary>
    /// Bitboard for our Bishops.
    /// </summary>
    public Bitboard Bishop
    {
      get{ return coBishop;}
      set{ coBishop = value;if(coBishop != 0 )coCount++;}
    }
    private Bitboard coBishop;
    /// <summary>
    /// Bitboard for our Knights.
    /// </summary>
    public Bitboard Knight
    {
      get{ return coKnight;}
      set{ coKnight = value;if(coKnight != 0 )coCount++;}
    }
    private Bitboard coKnight;
    /// <summary>
    /// Bitboard for our pawns.
    /// </summary>
    public Bitboard Pawn
    {
      get{ return coPawn;}
      set{ coPawn = value;if(coPawn != 0 )coCount++;}
    }
    private Bitboard coPawn;

    /// <summary>
    /// Public constructor, initiates bitboards to zero.
    /// </summary>
    public AttackingPieces()
    {
      Clear();
    }
    /// <summary>
    /// Sets all of the bitboards for each piece to zero.
    /// </summary>
    public void Clear()
    {
      coQueen=0;
      coRook=0;
      coBishop=0;
      coKnight=0;
      coPawn=0;
      coCount=0;
      DiagonalLR=0;
      DiagonalRL=0;
      Ranks=0;
      Files=0;
    }
  }

}
